home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / AIncludes / OSA.a < prev    next >
Encoding:
Text File  |  1994-03-28  |  51.0 KB  |  1,454 lines  |  [TEXT/MPS ]

  1. ;////////////////////////////////////////////////////////////////////////////////
  2. ;// OPEN SCRIPTING ARCHITECTURE: Client Interface
  3. ;////////////////////////////////////////////////////////////////////////////////
  4. ;// Copyright © 1992-1994 Apple Computer, Inc. All rights reserved.
  5. ;// Authors: Jens Alfke, William Cook, Donn Denman, and Warren Harris
  6. ;////////////////////////////////////////////////////////////////////////////////
  7. ;// This interface defines what it means to be a "scripting component."
  8. ;// Scripting components allow "scripts" to be loaded and executed.  This
  9. ;// interface does not define the way in which a particular scripting
  10. ;// component's scripts are editing and debugged.
  11. ;////////////////////////////////////////////////////////////////////////////////
  12.  
  13.  IF &TYPE('__INCLUDINGOSA__') = 'UNDEFINED' THEN
  14. __INCLUDINGOSA__ SET 1
  15.  
  16.  IF &TYPE('__INCLUDINGAPPLEEVENTS__') = 'UNDEFINED' THEN
  17.  INCLUDE 'AppleEvents.a'
  18.  ENDIF
  19.  
  20.  IF &TYPE('__INCLUDINGCOMPONENTS__') = 'UNDEFINED' THEN
  21.  INCLUDE 'Components.a'
  22.  ENDIF
  23.  
  24. ;//////// Conditional Compilation
  25.  
  26. ;////////////////////////////////////////////////////////////////////////////////
  27. ;// Types and Constants
  28. ;////////////////////////////////////////////////////////////////////////////////
  29.  
  30. kOSAComponentType    EQU    'osa '
  31. ;    // The componenent manager type code for components that
  32. ;    // support the OSA interface defined here.
  33.  
  34. kOSAGenericScriptingComponentSubtype EQU    'scpt'
  35.  
  36. kOSANullScript        EQU    0        
  37. ;    // No-script constant. 
  38.  
  39. kOSANullMode        EQU    0    ; sounds better
  40. kOSAModeNull        EQU    0    ; tastes consistent
  41. ;    // Some routines take flags that control their execution.  This constant
  42. ;    // declares default mode settings are used.
  43.  
  44. kOSASuite        EQU    'ascr'
  45. kOSARecordedText    EQU    'recd'
  46. ;    // Suite and event code of the RecordedText event. (See OSAStartRecording,
  47. ;    // below.)
  48.  
  49. ;////////////////////////////////////////////////////////////////////////////////
  50. ;// API Errors
  51. ;////////////////////////////////////////////////////////////////////////////////
  52.  
  53. errOSASystemError    EQU    -1750
  54. errOSAInvalidID        EQU    -1751
  55. errOSABadStorageType    EQU    -1752
  56. errOSAScriptError    EQU    -1753
  57. errOSABadSelector    EQU    -1754
  58. errOSASourceNotAvailable    EQU    -1756
  59. errOSANoSuchDialect    EQU    -1757
  60. errOSADataFormatObsolete    EQU    -1758
  61. errOSADataFormatTooNew    EQU    -1759
  62. errOSACorruptData    EQU    errAECorruptData
  63. errOSARecordingIsAlreadyOn    EQU    errAERecordingIsAlreadyOn
  64.  
  65. ;////////////////////////////////////////////////////////////////////////////////
  66. ;// Standard Script Errors
  67. ;////////////////////////////////////////////////////////////////////////////////
  68. ;// It is recommended that scripting components use the following set of error
  69. ;// codes to signal failure when applicable.  This enables applications that
  70. ;// use the OSA API to deal with some class of script errors in a less than 
  71. ;// ad hoc manner.  Scripting components are of course encouraged to return
  72. ;// component-specific errors when these don't apply.
  73. ;////////////////////////////////////////////////////////////////////////////////
  74.  
  75. ;//////// Dynamic errors:
  76. ;//
  77. ;// These errors result from data-dependent conditions and are typically
  78. ;// signaled at runtime.
  79.  
  80. errOSACantCoerce    EQU    errAECoercionFail
  81. ;    // Signaled when a value can't be coerced to the desired type. Similar
  82. ;    // to errOSATypeError except results from coercion.
  83.  
  84. errOSACantAccess    EQU    -1728
  85. ;    // Signaled when an object is not found in a container.
  86.  
  87. errOSACantAssign    EQU    -10006
  88. ;    // Signaled when an object cannot be set in a container.  Same as 
  89. ;    // AERegistry error errAEWriteDenied.
  90.  
  91. errOSAGeneralError    EQU    -2700
  92. ;    // Signaled by user scripts or applications when no actual error code
  93. ;    // is to be returned.  Simply means "an error has occurred".  Most useful
  94. ;    // in conjunction with an error message from the application.
  95.  
  96. errOSADivideByZero    EQU    -2701
  97. ;    // Signaled when there is an attempt to divide by zero.
  98.  
  99. errOSANumericOverflow    EQU    -2702
  100. ;    // Signaled when integer or real value is too large to be represented.
  101.  
  102. errOSACantLaunch    EQU    -2703
  103. ;    // Signaled when application can't be launched or when it is remote and
  104. ;    // program linking is not enabled.
  105.  
  106. errOSAAppNotHighLevelEventAware    EQU    -2704
  107. ;    // Signaled when an application can't respond to AppleEvents.
  108.  
  109. errOSACorruptTerminology    EQU    -2705
  110. ;    // Signaled when an application's terminology resource is not readable.
  111.  
  112. errOSAStackOverflow    EQU    -2706
  113. ;    // Signaled when the runtime stack overflows.
  114.  
  115. errOSAInternalTableOverflow    EQU    -2707
  116. ;    // Signaled when a runtime internal data structure overflows.
  117.  
  118. errOSADataBlockTooLarge    EQU    -2708
  119. ;    // Signaled when an intrinsic limitation is exceeded for the size of 
  120. ;    // a value or data structure.
  121.  
  122. errOSACantGetTerminology    EQU    -2709
  123. ;    // Signaled when we couldn't terminology even though it was there.
  124.  
  125. errOSACantCreate            EQU    -2710
  126. ;    //
  127.  
  128. ;//////// Component-specific dynamic script errors:
  129. ;//
  130. ;// The range -2720 thru -2739 is reserved for component-specific runtime errors.
  131. ;// (Note that error codes from different scripting components in this range will
  132. ;// overlap.)
  133.  
  134. ;//////// Static errors:
  135. ;//
  136. ;// These errors comprise what are commonly thought of as parse and compile-
  137. ;// time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  138. ;// of these may also occur at runtime.
  139.  
  140. errOSATypeError    EQU    errAEWrongDataType
  141. ;    // Signaled when data was not the right type and coercion is not allowed.
  142.  
  143. errOSAMessageNotUnderstood    EQU    errAEEventNotHandled
  144. ;    // Signaled when a message was sent to an object that didn't handle it.
  145.  
  146. errOSAUndefinedHandler    EQU    errAEHandlerNotFound
  147. ;    // Signaled when a function to be returned doesn't exist.  (Probably only
  148. ;    // useful in languages with first-class functions that distinguish between
  149. ;    // functions and other values (two name spaces). This is different from
  150. ;    // errOSAMessageNotUnderstood, which may be signaled when the method is
  151. ;    // invoked.
  152.  
  153. errOSAIllegalAccess    EQU    -1723
  154. ;    // Signaled when a container can never have the requested object.
  155.  
  156. errOSAIllegalIndex    EQU    errAEIllegalIndex
  157. ;    // Signaled when index was out of range. Specialization of errOSACantAccess.
  158.  
  159. errOSAIllegalRange    EQU    -1720
  160. ;    // Signaled when a range is screwy. Specialization of errOSACantAccess.
  161.  
  162. errOSAIllegalAssign    EQU    -10003
  163. ;    // Signaled when an object can never be set in a container.  Same as 
  164. ;    // AERegistry error errAENotModifiable.
  165.  
  166. errOSASyntaxError    EQU    -2740
  167. ;    // Signaled when a syntax error occurs. (e.g. "Syntax error" or
  168. ;    // "<this> can't go after <that>").
  169.  
  170. errOSASyntaxTypeError    EQU    -2741
  171. ;    // Signaled when another form of syntax was expected. (e.g. "expected
  172. ;    // a <type> but found <this>").
  173.  
  174. errOSATokenTooLong    EQU    -2742
  175. ;    // Signaled when a name or number is too long to be parsed.
  176.  
  177. errOSAMissingParameter    EQU    errAEDescNotFound
  178. ;    // Signaled when a parameter is missing for a function invocation.  Note
  179. ;    // that in some languages, this error may occur at runtime.
  180.  
  181. errOSAParameterMismatch    EQU    -1721
  182. ;    // Signaled when function is called with the wrong number of parameters,
  183. ;    // or a parameter pattern cannot be matched.
  184.  
  185. errOSADuplicateParameter    EQU    -2750
  186. ;    // Signaled when a formal parameter, local variable, or instance variable
  187. ;    // is specified more than once.
  188.  
  189. errOSADuplicateProperty    EQU    -2751
  190. ;    // Signaled when a formal parameter, local variable, or instance variable
  191. ;    // is specified more than once.
  192.  
  193. errOSADuplicateHandler    EQU    -2752
  194. ;    // Signaled when more than one handler is defined with the same name in 
  195. ;    // a scope where the language doesn't allow it.
  196.  
  197. errOSAUndefinedVariable    EQU    -2753
  198. ;    // Signaled when a variable is accessed that has no value.
  199.  
  200. errOSAInconsistentDeclarations    EQU    -2754
  201. ;    // Signaled when a variable is declared inconsistently in the same scope,
  202. ;    // such as both local and global.
  203.  
  204. errOSAControlFlowError    EQU    -2755
  205. ;    // Signaled when illegal control flow occurs in an application (no catcher
  206. ;    // for throw, non-lexical loop exit, etc.).
  207.  
  208. ;//////// Component-specific static script errors:
  209. ;//
  210. ;// The range -2760 thru -2779 is reserved for component-specific parsing and
  211. ;// compile-time errors. (Note that error codes from different scripting
  212. ;// components in this range will overlap.)
  213.  
  214. ;//////// Dialect-specific script errors:
  215. ;//
  216. ;// The range -2780 thru -2799 is reserved for dialect specific error codes for
  217. ;// scripting components that support dialects. (Note that error codes from
  218. ;// different scripting components in this range will overlap, as well as error
  219. ;// codes from different dialects in the same scripting component.)
  220.  
  221. ;////////////////////////////////////////////////////////////////////////////////
  222. ;// OSA Interface Descriptions
  223. ;////////////////////////////////////////////////////////////////////////////////
  224. ;// The OSA Interface is broken down into a required interface, and several
  225. ;// optional interfaces to support additional functionality.  A given scripting
  226. ;// component may choose to support only some of the optional interfaces in
  227. ;// addition to the basic interface.  The OSA Component Flags may be used to 
  228. ;// query the Component Manager to find a scripting component with a particular
  229. ;// capability, or determine if a particular scripting component supports a 
  230. ;// particular capability.
  231. ;////////////////////////////////////////////////////////////////////////////////
  232.  
  233. ;//////// OSA Component Flags:
  234.  
  235. kOSASupportsCompiling    EQU    $0002
  236. kOSASupportsGetSource    EQU    $0004
  237. kOSASupportsAECoercion    EQU    $0008
  238. kOSASupportsAESending    EQU    $0010
  239. kOSASupportsRecording    EQU    $0020
  240. kOSASupportsConvenience    EQU    $0040
  241. kOSASupportsDialects    EQU    $0080
  242. kOSASupportsEventHandling    EQU    $0100
  243.  
  244. ;//////// Component Selectors:
  245.  
  246. ;// Basic Scripting:
  247. kOSASelectLoad        EQU    $0001
  248. kOSASelectStore        EQU    $0002
  249. kOSASelectExecute    EQU    $0003
  250. kOSASelectDisplay    EQU    $0004
  251. kOSASelectScriptError    EQU    $0005
  252. kOSASelectDispose    EQU    $0006
  253. kOSASelectSetScriptInfo    EQU    $0007
  254. kOSASelectGetScriptInfo    EQU    $0008
  255. kOSASelectSetActiveProc    EQU    $0009
  256. kOSASelectGetActiveProc    EQU    $000A
  257. ;// Compiling:
  258. kOSASelectScriptingComponentName EQU    $0102
  259. kOSASelectCompile    EQU    $0103
  260. kOSASelectCopyID    EQU    $0104
  261. ;// GetSource:
  262. kOSASelectGetSource    EQU    $0201
  263. ;// AECoercion:
  264. kOSASelectCoerceFromDesc    EQU    $0301
  265. kOSASelectCoerceToDesc    EQU    $0302
  266. ;// AESending:
  267. kOSASelectSetSendProc    EQU    $0401
  268. kOSASelectGetSendProc    EQU    $0402
  269. kOSASelectSetCreateProc    EQU    $0403
  270. kOSASelectGetCreateProc    EQU    $0404
  271. kOSASelectSetDefaultTarget    EQU    $0405
  272. ;// Recording:
  273. kOSASelectStartRecording    EQU    $0501
  274. kOSASelectStopRecording    EQU    $0502
  275. ;// Convenience:
  276. kOSASelectLoadExecute    EQU    $0601
  277. kOSASelectCompileExecute    EQU    $0602
  278. kOSASelectDoScript    EQU    $0603
  279. ;// Dialects:
  280. kOSASelectSetCurrentDialect    EQU    $0701
  281. kOSASelectGetCurrentDialect    EQU    $0702
  282. kOSASelectAvailableDialects    EQU    $0703
  283. kOSASelectGetDialectInfo    EQU    $0704
  284. kOSASelectAvailableDialectCodeList EQU    $0705
  285. ;// Event Handling:
  286. kOSASelectSetResumeDispatchProc    EQU    $0801
  287. kOSASelectGetResumeDispatchProc    EQU    $0802
  288. kOSASelectExecuteEvent    EQU    $0803
  289. kOSASelectDoEvent    EQU    $0804
  290. kOSASelectMakeContext    EQU    $0805
  291.  
  292. kOSASelectComponentSpecificStart EQU    $1001
  293. ;    // scripting component specific selectors are added beginning with this
  294. ;    // value
  295.  
  296. ;//////// Mode Flags:
  297. ;//
  298. ;// Warning: These should not conflict with the AESend mode flags in
  299. ;// AppleEvents.h, because we may want to use them as OSA mode flags too.
  300.  
  301. kOSAModePreventGetSource    EQU    $00000001
  302. ;    // This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  303. ;    // instruct the scripting component to not retain the "source" of an
  304. ;    // expression.  This will cause the OSAGetSource call to return the error
  305. ;    // errOSASourceNotAvailable if used.  However, some scripting components
  306. ;    // may not retain the source anyway.  This is mainly used when either space
  307. ;    // efficiency is desired, or a script is to be "locked" so that its
  308. ;    // implementation may not be viewed.
  309.  
  310. kOSAModeNeverInteract    EQU    kAENeverInteract
  311. kOSAModeCanInteract    EQU    kAECanInteract
  312. kOSAModeAlwaysInteract    EQU    kAEAlwaysInteract
  313. kOSAModeDontReconnect    EQU    kAEDontReconnect
  314. ;    // These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  315. ;    // OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  316. ;    // indicate whether or not the script may interact with the user, switch
  317. ;    // layer or reconnect if necessary.  Any AppleEvents will be sent with the
  318. ;    // corresponding AESend mode supplied.
  319.  
  320. kOSAModeCantSwitchLayer    EQU    $00000040
  321. ;    // This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  322. ;    // OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  323. ;    // indicate whether or not AppleEvents should be sent with the
  324. ;    // kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  325. ;    // opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  326. ;    // provide a more convenient default, i.e. not supplying any mode
  327. ;    // (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  328. ;    // the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  329. ;    // without kAECanSwitchLayer.
  330.  
  331. kOSAModeDoRecord    EQU    $00001000
  332. ;    // This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  333. ;    // OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  334. ;    // indicate whether or not AppleEvents should be sent with the kAEDontRecord
  335. ;    // mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  336. ;    // the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  337. ;    // default, i.e. not supplying any mode (kOSAModeNull) means to send events
  338. ;    // with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  339. ;    // cause AESend to be called without kAEDontRecord.
  340.  
  341. kOSAModeCompileIntoContext    EQU    $00000002
  342. ;    // This is a mode flag for OSACompile that indicates that a context should
  343. ;    // be created as the result of compilation. All handler definitions are
  344. ;    // inserted into the new context, and variables are initialized by
  345. ;    // evaluating their initial values in a null context (i.e. they must be
  346. ;    // constant expressions).
  347.  
  348. kOSAModeAugmentContext    EQU    $00000004
  349. ;    // This is a mode flag for OSACompile that indicates that the previous
  350. ;    // script ID (input to OSACompile) should be augmented with any new
  351. ;    // definitions in the sourceData rather than replaced with a new script.
  352. ;    // This means that the previous script ID must designate a context.
  353. ;    // The presence of this flag causes the kOSAModeCompileIntoContext flag
  354. ;    // to be implicitly used, causing any new definitions to be initialized
  355. ;    // in a null context.
  356.  
  357. kOSAModeDisplayForHumans    EQU    $00000008
  358. ;    // This mode flag may be passed to OSADisplay or OSADoScript to indicate
  359. ;    // that output only need be human-readable, not re-compilable by OSACompile.
  360. ;    // If used, output may be arbitrarily "beautified", e.g. quotes may be left
  361. ;    // off of string values, long lists may have elipses, etc.
  362.  
  363. kOSAModeDontStoreParent    EQU    $00004000
  364. ;    // This mode flag may be passed to OSAStore in the case where the scriptID
  365. ;    // is a context.  This causes the context to be saved, but not the context's
  366. ;    // parent context.  When the stored context is loaded back in, the parent
  367. ;    // will be kOSANullScript.
  368.  
  369. kOSAModeDispatchToDirectObject    EQU $00020000
  370. ;    // This mode flag may be passed to OSAExecuteEvent to cause the event to
  371. ;    // be dispatched to the direct object of the event. The direct object (or
  372. ;    // subject attribute if the direct object is a non-object specifier) will
  373. ;    // be resolved, and the resulting script object will be the recipient of
  374. ;    // the message. The context argument to OSAExecuteEvent will serve as the
  375. ;    // root of the lookup/resolution process.
  376. kOSAModeDontGetDataForArguments    EQU    $00040000
  377. ;    // This mode flag may be passed to OSAExecuteEvent to indicate that
  378. ;    // components do not have to get the data of object specifier arguments.
  379.  
  380. ;////////////////////////////////////////////////////////////////////////////////
  381. ;// OSA Basic Scripting Interface
  382. ;////////////////////////////////////////////////////////////////////////////////
  383. ;// Scripting components must at least support the Basic Scripting interface.
  384. ;////////////////////////////////////////////////////////////////////////////////
  385.  
  386. ;//////// Loading and Storing Scripts:
  387. ;//
  388. ;// These routines allow scripts to be loaded and stored in their internal
  389. ;// (possibly compiled, non-text) representation.
  390.  
  391. kOSAScriptResourceType    EQU    kOSAGenericScriptingComponentSubtype
  392. ;    // Resource type for scripts.
  393.     
  394. typeOSAGenericStorage    EQU    kOSAScriptResourceType
  395. ;    // Default type given to OSAStore which creates "generic" loadable script
  396. ;    // data descriptors.
  397.  
  398. ;pascal OSAError
  399. ;OSALoad(ComponentInstance    scriptingComponent,
  400. ;        const AEDesc*    scriptData,
  401. ;        long        modeFlags,
  402. ;        OSAID*        resultingScriptID);
  403. ;    //
  404. ;    // Errors:
  405. ;    //    badComponentInstance    invalid scripting component instance
  406. ;    //     errOSASystemError
  407. ;    //     errOSABadStorageType:    scriptData not for this scripting component
  408. ;    //     errOSACorruptData:    data seems to be corrupt
  409. ;    //     errOSADataFormatObsolete    script data format is no longer supported
  410. ;    //     errOSADataFormatTooNew    script data format is from a newer version
  411. ;    // 
  412. ;    // ModeFlags:
  413. ;    //    kOSAModePreventGetSource
  414.  
  415.         MACRO
  416.         _OSALoad
  417.         MOVE.L    #((12<<16)|kOSASelectLoad),-(A7)
  418.         MOVEQ    #$0,D0
  419.         DC.W    $A82A    ; TB 002A
  420.         ENDM
  421.  
  422. ;pascal OSAError
  423. ;OSAStore(ComponentInstance    scriptingComponent, 
  424. ;         OSAID        scriptID, 
  425. ;         DescType    desiredType,
  426. ;         long        modeFlags,
  427. ;         AEDesc*    resultingScriptData);
  428. ;    //
  429. ;    // Errors:
  430. ;    //    badComponentInstance    invalid scripting component instance
  431. ;    //     errOSASystemError
  432. ;    //     errOSAInvalidID
  433. ;    //     errOSABadStorageType:    desiredType not for this scripting component
  434. ;    // 
  435. ;    // ModeFlags:
  436. ;    //    kOSAModePreventGetSource
  437. ;    //    kOSAModeDontStoreParent
  438.  
  439.         MACRO
  440.         _OSAStore
  441.         MOVE.L    #((16<<16)|kOSASelectStore),-(A7)
  442.         MOVEQ    #$0,D0
  443.         DC.W    $A82A    ; TB 002A
  444.         ENDM
  445.  
  446. ;//////// Executing Scripts:
  447.  
  448. ;pascal OSAError
  449. ;OSAExecute(ComponentInstance    scriptingComponent,
  450. ;           OSAID    compiledScriptID,
  451. ;           OSAID    contextID,
  452. ;           long    modeFlags,
  453. ;           OSAID*    resultingScriptValueID);
  454. ;    // This call runs a script.  The contextID represents the environment
  455. ;    // with which global variables in the script are resolved.  The constant
  456. ;    // kOSANullScript may be used for the contextID if the application wishes
  457. ;    // to not deal with context directly (a default one is associated with each
  458. ;    // scripting component instance).  The resultingScriptValueID is the 
  459. ;    // result of evaluation, and contains a value which may be displayed using
  460. ;    // the OSAGetSource call.  The modeFlags convey scripting component
  461. ;    // specific information.
  462. ;    //
  463. ;    // Errors:
  464. ;    //    badComponentInstance    invalid scripting component instance
  465. ;    //     errOSASystemError
  466. ;    //     errOSAInvalidID
  467. ;    //     errOSAScriptError:    the executing script got an error
  468. ;    //
  469. ;    // ModeFlags:
  470. ;    //    kOSAModeNeverInteract
  471. ;    //    kOSAModeCanInteract
  472. ;    //    kOSAModeAlwaysInteract
  473. ;    //    kOSAModeCantSwitchLayer
  474. ;    //    kOSAModeDontReconnect
  475. ;    //    kOSAModeDoRecord
  476.  
  477.         MACRO
  478.         _OSAExecute
  479.         MOVE.L    #((16<<16)|kOSASelectExecute),-(A7)
  480.         MOVEQ    #$0,D0
  481.         DC.W    $A82A    ; TB 002A
  482.         ENDM
  483.  
  484. ;//////// Displaying results:
  485.  
  486. ;pascal OSAError
  487. ;OSADisplay(ComponentInstance    scriptingComponent,
  488. ;           OSAID    scriptValueID,
  489. ;           DescType    desiredType,
  490. ;           long    modeFlags,
  491. ;           AEDesc*    resultingText);
  492. ;    // This call is used to convert results (script value IDs) into displayable
  493. ;    // text. The desiredType should be at least typeChar, and modeFlags are
  494. ;    // scripting system specific flags to control the formatting of the
  495. ;    // resulting text. This call differs from OSAGetSource in that (1) it
  496. ;    // always produces at least typeChar, (2) is only works on script values,
  497. ;    // (3) it may display it's output in non-compilable form (e.g. without
  498. ;    // string quotes, elipses inserted in long and/or circular lists, etc.) and
  499. ;    // (4) it is required by the basic scripting interface.
  500. ;    //
  501. ;    // Errors:
  502. ;    //    badComponentInstance    invalid scripting component instance
  503. ;    //     errOSASystemError
  504. ;    //     errOSAInvalidID
  505. ;    //     errAECoercionFail:    desiredType not supported by scripting component
  506. ;    //
  507. ;    // ModeFlags:
  508. ;    //    kOSAModeDisplayForHumans
  509.  
  510.         MACRO
  511.         _OSADisplay
  512.         MOVE.L    #((16<<16)|kOSASelectDisplay),-(A7)
  513.         MOVEQ    #$0,D0
  514.         DC.W    $A82A    ; TB 002A
  515.         ENDM
  516.  
  517. ;//////// Getting Error Information:
  518.  
  519. ;pascal OSAError
  520. ;OSAScriptError(ComponentInstance    scriptingComponent,
  521. ;    OSType        selector,
  522. ;    DescType        desiredType,
  523. ;    AEDesc*        resultingErrorDescription);
  524. ;    // Whenever script execution returns errOSAExecutionError, this routine
  525. ;    // may be used to get information about that error.  The selector describes
  526. ;    // the type of information desired about the error (various selectors are
  527. ;    // listed below).  The desiredType indicates the data type of the result
  528. ;    // desired for that selector.
  529. ;    //
  530. ;    // Errors:
  531. ;    //    badComponentInstance    invalid scripting component instance
  532. ;    //     errOSASystemError
  533. ;    //    errOSABadSelector:    selector not supported by scripting component
  534. ;    //     errAECoercionFail:    desiredType not supported by scripting component
  535.  
  536.         MACRO
  537.         _OSAScriptError
  538.         MOVE.L    #((12<<16)|kOSASelectScriptError),-(A7)
  539.         MOVEQ    #$0,D0
  540.         DC.W    $A82A    ; TB 002A
  541.         ENDM
  542.  
  543. ;// OSAScriptError selectors:
  544.  
  545. kOSAErrorNumber        EQU    keyErrorNumber
  546. ;    // This selector is used to determine the error number of a script error.
  547. ;    // These error numbers may be either system error numbers, or error numbers
  548. ;    // that are scripting component specific.
  549. ;    // Required desiredTypes:
  550. ;    //    typeShortInteger
  551.  
  552. kOSAErrorMessage    EQU    keyErrorString
  553. ;    // This selector is used to determine the full error message associated
  554. ;    // with the error number.  It should include the name of the application
  555. ;    // which caused the error, as well as the specific error that occurred.
  556. ;    // This selector is sufficient for simple error reporting (but see
  557. ;    // kOSAErrorBriefMessage, below).
  558. ;    // Required desiredTypes:
  559. ;    //    typeChar                    error message string
  560.  
  561. kOSAErrorBriefMessage    EQU    'errb'
  562. ;    // This selector is used to determine a brief error message associated with
  563. ;    // the error number.  This message and should not mention the name of the
  564. ;    // application which caused the error, any partial results or offending
  565. ;    // object (see kOSAErrorApp, kOSAErrorPartialResult and
  566. ;    // kOSAErrorOffendingObject, below).
  567. ;    // Required desiredTypes:
  568. ;    //    typeChar                    brief error message string
  569.  
  570. kOSAErrorApp        EQU    'erap'
  571. ;    // This selector is used to determine which application actually got the
  572. ;    // error (if it was the result of an AESend), or the current application
  573. ;    // if ....
  574. ;    // Required desiredTypes:
  575. ;    //    typeProcessSerialNumber        PSN of the errant application
  576. ;    //    typeChar                    name of the errant application
  577.  
  578. kOSAErrorPartialResult    EQU    'ptlr'
  579. ;    // This selector is used to determine any partial result returned by an 
  580. ;    // operation. If an AESend call failed, but a partial result was returned,
  581. ;    // then the partial result may be returned as an AEDesc.
  582. ;    // Required desiredTypes:
  583. ;    //    typeBest                    AEDesc of any partial result
  584.  
  585. kOSAErrorOffendingObject    EQU    'erob'
  586. ;    // This selector is used to determine any object which caused the error
  587. ;    // that may have been indicated by an application.  The result is an 
  588. ;    // AEDesc.
  589. ;    // Required desiredTypes:
  590. ;    //    typeBest                    AEDesc of any offending object
  591.     
  592. kOSAErrorExpectedType    EQU    'errt'
  593. ;    // This selector is used to determine the type expected by a coercion 
  594. ;    // operation if a type error occurred. 
  595.  
  596. kOSAErrorRange    EQU    'erng'
  597. ;    // This selector is used to determine the source text range (start and 
  598. ;    // end positions) of where the error occurred.
  599. ;    // Required desiredTypes:
  600. ;    //    typeOSAErrorRange
  601.  
  602. typeOSAErrorRange    EQU    'erng'
  603. ;    // An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  604. ;    // of type short.
  605. keyOSASourceStart    EQU    'srcs'
  606. ;    // Field of a typeOSAErrorRange record of typeShortInteger.
  607. keyOSASourceEnd        EQU    'srce'
  608. ;    // Field of a typeOSAErrorRange record of typeShortInteger.
  609.  
  610. ;//////// Disposing Script IDs:
  611.  
  612. ;pascal OSAError
  613. ;OSADispose(ComponentInstance    scriptingComponent,
  614. ;           OSAID    scriptID);
  615. ;    // Disposes a script or context.
  616. ;    //
  617. ;    // Errors:
  618. ;    //    badComponentInstance    invalid scripting component instance
  619. ;    //     errOSASystemError
  620. ;    //     errOSAInvalidID
  621.  
  622.         MACRO
  623.         _OSADispose
  624.         MOVE.L    #((4<<16)|kOSASelectDispose),-(A7)
  625.         MOVEQ    #$0,D0
  626.         DC.W    $A82A    ; TB 002A
  627.         ENDM
  628.  
  629. ;//////// Getting and Setting Script Information:
  630.  
  631. ;pascal OSAError
  632. ;OSASetScriptInfo(ComponentInstance    scriptingComponent,
  633. ;      OSAID        scriptID,
  634. ;      OSType        selector,
  635. ;      long        value);
  636. ;    //
  637. ;    // Errors:
  638. ;    //    badComponentInstance    invalid scripting component instance
  639. ;    //     errOSASystemError
  640. ;    //     errOSAInvalidID
  641. ;    //    errOSABadSelector:    selector not supported by scripting component
  642. ;    //                             or selector not for this scriptID
  643.  
  644.         MACRO
  645.         _OSASetScriptInfo
  646.         MOVE.L    #((12<<16)|kOSASelectSetScriptInfo),-(A7)
  647.         MOVEQ    #$0,D0
  648.         DC.W    $A82A    ; TB 002A
  649.         ENDM
  650.  
  651. ;pascal OSAError
  652. ;OSAGetScriptInfo(ComponentInstance    scriptingComponent,
  653. ;      OSAID        scriptID,
  654. ;      OSType        selector,
  655. ;      long*        result);
  656. ;    //
  657. ;    // Errors:
  658. ;    //    badComponentInstance    invalid scripting component instance
  659. ;    //     errOSASystemError
  660. ;    //     errOSAInvalidID
  661. ;    //    errOSABadSelector:    selector not supported by scripting component
  662. ;    //                             or selector not for this scriptID
  663.  
  664.         MACRO
  665.         _OSAGetScriptInfo
  666.         MOVE.L    #((12<<16)|kOSASelectGetScriptInfo),-(A7)
  667.         MOVEQ    #$0,D0
  668.         DC.W    $A82A    ; TB 002A
  669.         ENDM
  670.  
  671. kOSAScriptIsModified    EQU    'modi'
  672. ;    // Selector returns boolean.
  673.  
  674. kOSAScriptIsTypeCompiledScript    EQU    'cscr'
  675. ;    // Selector returns boolean.
  676.     
  677. kOSAScriptIsTypeScriptValue    EQU    'valu'
  678. ;    // Selector returns boolean.
  679.  
  680. kOSAScriptIsTypeScriptContext    EQU    'cntx'
  681. ;    // Selector returns boolean.
  682.  
  683. kOSAScriptBestType    EQU    'best'
  684. ;    // Selector returns a DescType which may be passed to OSACoerceToDesc.
  685.  
  686. kOSACanGetSource    EQU    'gsrc'
  687. ;    // This selector is used to determine whether a script has source 
  688. ;    // associated with it that when given to OSAGetSource, the call will not
  689. ;    // fail.  The selector returns a boolean.
  690.  
  691. ;//////// Manipulating the ActiveProc:
  692. ;//
  693. ;// Scripting systems will supply default values for these procedures if they
  694. ;// are not set by the client:
  695.  
  696. ;pascal OSAError
  697. ;OSASetActiveProc(ComponentInstance    scriptingComponent,
  698. ;      OSAActiveProcPtr    activeProc,
  699. ;      long        refCon);
  700. ;    // If activeProc is nil, the default activeProc is used.
  701. ;    //
  702. ;    // Errors:
  703. ;    //    badComponentInstance    invalid scripting component instance
  704. ;    //     errOSASystemError
  705.  
  706.         MACRO
  707.         _OSASetActiveProc
  708.         MOVE.L    #((8<<16)|kOSASelectSetActiveProc),-(A7)
  709.         MOVEQ    #$0,D0
  710.         DC.W    $A82A    ; TB 002A
  711.         ENDM
  712.  
  713. ;pascal OSAError
  714. ;OSAGetActiveProc(ComponentInstance    scriptingComponent,
  715. ;      OSAActiveProcPtr*    activeProc,
  716. ;      long*        refCon);
  717. ;    //
  718. ;    // Errors:
  719. ;    //    badComponentInstance    invalid scripting component instance
  720. ;    //     errOSASystemError
  721.  
  722.         MACRO
  723.         _OSAGetActiveProc
  724.         MOVE.L    #((8<<16)|kOSASelectGetActiveProc),-(A7)
  725.         MOVEQ    #$0,D0
  726.         DC.W    $A82A    ; TB 002A
  727.         ENDM
  728.  
  729. ;////////////////////////////////////////////////////////////////////////////////
  730. ;// OSA Optional Compiling Interface
  731. ;////////////////////////////////////////////////////////////////////////////////
  732. ;// Scripting components that support the Compiling interface have the 
  733. ;// kOSASupportsCompiling bit set in it's ComponentDescription.
  734. ;////////////////////////////////////////////////////////////////////////////////
  735.  
  736. ;pascal OSAError
  737. ;OSAScriptingComponentName(ComponentInstance    scriptingComponent,
  738. ;               AEDesc*    resultingScriptingComponentName);
  739. ;    // Given a scripting component, this routine returns the name of that
  740. ;    // scripting component in a type that is coercable to text (typeChar).
  741. ;    // The generic scripting component returns the name of the default
  742. ;    // scripting component.  This name should be sufficient to convey to the
  743. ;    // user the kind of script (syntax) he is expected to write.
  744. ;    //
  745. ;    // Errors:
  746. ;    //    badComponentInstance    invalid scripting component instance
  747. ;    //     errOSASystemError
  748.  
  749.         MACRO
  750.         _OSAScriptingComponentName
  751.         MOVE.L    #((4<<16)|kOSASelectScriptingComponentName),-(A7)
  752.         MOVEQ    #$0,D0
  753.         DC.W    $A82A    ; TB 002A
  754.         ENDM
  755.  
  756. ;pascal OSAError
  757. ;OSACompile(ComponentInstance    scriptingComponent,
  758. ;           const AEDesc*    sourceData,
  759. ;           long    modeFlags,
  760. ;           OSAID*    previousAndResultingScriptID);
  761. ;    // Coerces input desc (possibly text) into a script's internal format.
  762. ;    // Once compiled, the script is ready to run.  The modeFlags convey
  763. ;    // scripting component specific information.  The previous script ID
  764. ;    // (result parameter) is made to refer to the newly compiled script,
  765. ;    // unless it was originally kOSANullScript.  In this case a new script
  766. ;    // ID is created and used.
  767. ;    //
  768. ;    // Errors:
  769. ;    //    badComponentInstance    invalid scripting component instance
  770. ;    //     errOSASystemError
  771. ;    //    errAECoercionFail:        sourceData is not compilable
  772. ;    //     errOSAScriptError:        sourceData was a bad script (syntax error)
  773. ;    //     errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  774. ;    //                            valid on input
  775. ;    //
  776. ;    // ModeFlags:
  777. ;    //    kOSAModePreventGetSource
  778. ;    //    kOSAModeCompileIntoContext
  779. ;    //    kOSAModeAugmentContext
  780. ;    //    kOSAModeNeverInteract
  781. ;    //    kOSAModeCanInteract
  782. ;    //    kOSAModeAlwaysInteract
  783. ;    //    kOSAModeCantSwitchLayer
  784. ;    //    kOSAModeDontReconnect
  785. ;    //    kOSAModeDoRecord
  786.  
  787.         MACRO
  788.         _OSACompile
  789.         MOVE.L    #((12<<16)|kOSASelectCompile),-(A7)
  790.         MOVEQ    #$0,D0
  791.         DC.W    $A82A    ; TB 002A
  792.         ENDM
  793.  
  794. ;pascal OSAError
  795. ;OSACopyID(ComponentInstance    scriptingComponent,
  796. ;          OSAID    fromID,
  797. ;          OSAID*    toID);
  798. ;    // If toID is a reference to kOSANullScript then it is updated to have a
  799. ;    // new scriptID value.  This call can be used to perform undo or revert
  800. ;    // operations on scripts. 
  801. ;    //
  802. ;    // Errors:
  803. ;    //    badComponentInstance    invalid scripting component instance
  804. ;    //     errOSASystemError
  805. ;    //     errOSAInvalidID
  806.  
  807.         MACRO
  808.         _OSACopyID
  809.         MOVE.L    #((8<<16)|kOSASelectCopyID),-(A7)
  810.         MOVEQ    #$0,D0
  811.         DC.W    $A82A    ; TB 002A
  812.         ENDM
  813.  
  814. ;////////////////////////////////////////////////////////////////////////////////
  815. ;// OSA Optional GetSource Interface
  816. ;////////////////////////////////////////////////////////////////////////////////
  817. ;// Scripting components that support the GetSource interface have the 
  818. ;// kOSASupportsGetSource bit set in it's ComponentDescription.
  819. ;////////////////////////////////////////////////////////////////////////////////
  820.  
  821. ;pascal OSAError
  822. ;OSAGetSource(ComponentInstance    scriptingComponent,
  823. ;             OSAID    scriptID,
  824. ;             DescType    desiredType,
  825. ;             AEDesc*    resultingSourceData);
  826. ;    // This routine causes a compiled script to be output in a form (possibly
  827. ;    // text) such that it is suitable to be passed back to OSACompile.
  828. ;    //
  829. ;    // Errors:
  830. ;    //    badComponentInstance    invalid scripting component instance
  831. ;    //     errOSASystemError
  832. ;    //     errOSAInvalidID
  833. ;    //    errOSASourceNotAvailable    can't get source for this scriptID
  834.  
  835.         MACRO
  836.         _OSAGetSource
  837.         MOVE.L    #((12<<16)|kOSASelectGetSource),-(A7)
  838.         MOVEQ    #$0,D0
  839.         DC.W    $A82A    ; TB 002A
  840.         ENDM
  841.  
  842. ;////////////////////////////////////////////////////////////////////////////////
  843. ;// OSA Optional AECoercion Interface
  844. ;////////////////////////////////////////////////////////////////////////////////
  845. ;// Scripting components that support the AECoercion interface have the 
  846. ;// kOSASupportsAECoercion bit set in it's ComponentDescription.
  847. ;////////////////////////////////////////////////////////////////////////////////
  848.  
  849. ;pascal OSAError
  850. ;OSACoerceFromDesc(ComponentInstance    scriptingComponent,
  851. ;       const AEDesc*    scriptData,
  852. ;       long        modeFlags,
  853. ;       OSAID*        resultingScriptID);
  854. ;    // This routine causes script data to be coerced into a script value.
  855. ;    // If the scriptData is an AppleEvent, then the resultingScriptID is a
  856. ;    // compiled script ID (mode flags for OSACompile may be used in this case).
  857. ;    // Other scriptData descriptors create script value IDs.
  858. ;    //
  859. ;    // Errors:
  860. ;    //    badComponentInstance    invalid scripting component instance
  861. ;    //     errOSASystemError
  862. ;    //
  863. ;    // ModeFlags:
  864. ;    //    kOSAModePreventGetSource
  865. ;    //    kOSAModeCompileIntoContext
  866. ;    //    kOSAModeNeverInteract
  867. ;    //    kOSAModeCanInteract
  868. ;    //    kOSAModeAlwaysInteract
  869. ;    //    kOSAModeCantSwitchLayer
  870. ;    //    kOSAModeDontReconnect
  871. ;    //    kOSAModeDoRecord
  872.  
  873.         MACRO
  874.         _OSACoerceFromDesc
  875.         MOVE.L    #((12<<16)|kOSASelectCoerceFromDesc),-(A7)
  876.         MOVEQ    #$0,D0
  877.         DC.W    $A82A    ; TB 002A
  878.         ENDM
  879.  
  880. ;pascal OSAError
  881. ;OSACoerceToDesc(ComponentInstance    scriptingComponent,
  882. ;     OSAID        scriptID,
  883. ;     DescType        desiredType,
  884. ;     long        modeFlags,
  885. ;     AEDesc*        result);
  886. ;    // This routine causes a script value to be coerced into any desired form.
  887. ;    // If the scriptID denotes a compiled script, then it may be coerced to 
  888. ;    // typeAppleEvent.
  889. ;    //
  890. ;    // Errors:
  891. ;    //    badComponentInstance    invalid scripting component instance
  892. ;    //     errOSASystemError
  893. ;    //     errOSAInvalidID
  894.  
  895.         MACRO
  896.         _OSACoerceToDesc
  897.         MOVE.L    #((16<<16)|kOSASelectCoerceToDesc),-(A7)
  898.         MOVEQ    #$0,D0
  899.         DC.W    $A82A    ; TB 002A
  900.         ENDM
  901.  
  902. ;////////////////////////////////////////////////////////////////////////////////
  903. ;// OSA Optional AESending Interface
  904. ;////////////////////////////////////////////////////////////////////////////////
  905. ;// Scripting components that support the AESending interface have the 
  906. ;// kOSASupportsAESending bit set in it's ComponentDescription.
  907. ;////////////////////////////////////////////////////////////////////////////////
  908.  
  909. ;// Scripting systems will supply default values for these procedures if they
  910. ;// are not set by the client:
  911.  
  912. ;pascal OSAError
  913. ;OSASetSendProc(ComponentInstance    scriptingComponent,
  914. ;    AESendProcPtr        sendProc,
  915. ;    long        refCon);
  916. ;    // If sendProc is nil, the default sendProc is used.
  917. ;    //
  918. ;    // Errors:
  919. ;    //    badComponentInstance    invalid scripting component instance
  920. ;    //     errOSASystemError
  921.  
  922.         MACRO
  923.         _OSASetSendProc
  924.         MOVE.L    #((8<<16)|kOSASelectSetSendProc),-(A7)
  925.         MOVEQ    #$0,D0
  926.         DC.W    $A82A    ; TB 002A
  927.         ENDM
  928.  
  929. ;pascal OSAError
  930. ;OSAGetSendProc(ComponentInstance    scriptingComponent,
  931. ;    AESendProcPtr*        sendProc,
  932. ;    long*        refCon);
  933. ;    //
  934. ;    // Errors:
  935. ;    //    badComponentInstance    invalid scripting component instance
  936. ;    //     errOSASystemError
  937.  
  938.         MACRO
  939.         _OSAGetSendProc
  940.         MOVE.L    #((8<<16)|kOSASelectGetSendProc),-(A7)
  941.         MOVEQ    #$0,D0
  942.         DC.W    $A82A    ; TB 002A
  943.         ENDM
  944.  
  945. ;pascal OSAError
  946. ;OSASetCreateProc(ComponentInstance    scriptingComponent,
  947. ;      AECreateAppleEventProcPtr    createProc,
  948. ;      long        refCon);
  949. ;    // If createProc is nil, the default createProc is used.
  950. ;    //
  951. ;    // Errors:
  952. ;    //    badComponentInstance    invalid scripting component instance
  953. ;    //     errOSASystemError
  954.  
  955.         MACRO
  956.         _OSASetCreateProc
  957.         MOVE.L    #((8<<16)|kOSASelectSetCreateProc),-(A7)
  958.         MOVEQ    #$0,D0
  959.         DC.W    $A82A    ; TB 002A
  960.         ENDM
  961.  
  962. ;pascal OSAError
  963. ;OSAGetCreateProc(ComponentInstance    scriptingComponent,
  964. ;      AECreateAppleEventProcPtr*    createProc,
  965. ;      long*        refCon);
  966. ;    //
  967. ;    // Errors:
  968. ;    //    badComponentInstance    invalid scripting component instance
  969. ;    //     errOSASystemError
  970.  
  971.         MACRO
  972.         _OSAGetCreateProc
  973.         MOVE.L    #((8<<16)|kOSASelectGetCreateProc),-(A7)
  974.         MOVEQ    #$0,D0
  975.         DC.W    $A82A    ; TB 002A
  976.         ENDM
  977.  
  978. ;pascal OSAError
  979. ;OSASetDefaultTarget(ComponentInstance    scriptingComponent,
  980. ;         const AEAddressDesc*    target);
  981. ;    // This routine sets the default target application for AE sending.
  982. ;    // It also establishes the default target from which terminologies come.
  983. ;    // It is effectively like having an AppleScript "tell" statement around
  984. ;    // the entire program.  If this routine is not called, or if the target 
  985. ;    // is a null AEDesc, then the current application is the default target.
  986. ;    //
  987. ;    // Errors:
  988. ;    //    badComponentInstance    invalid scripting component instance
  989. ;    //     errOSASystemError
  990.  
  991.         MACRO
  992.         _OSASetDefaultTarget
  993.         MOVE.L    #((4<<16)|kOSASelectSetDefaultTarget),-(A7)
  994.         MOVEQ    #$0,D0
  995.         DC.W    $A82A    ; TB 002A
  996.         ENDM
  997.  
  998. ;////////////////////////////////////////////////////////////////////////////////
  999. ;// OSA Optional Recording Interface
  1000. ;////////////////////////////////////////////////////////////////////////////////
  1001. ;// Scripting components that support the Recording interface have the 
  1002. ;// kOSASupportsRecording bit set in it's ComponentDescription.
  1003. ;////////////////////////////////////////////////////////////////////////////////
  1004.  
  1005. ;pascal OSAError
  1006. ;OSAStartRecording(ComponentInstance    scriptingComponent,
  1007. ;       OSAID*        compiledScriptToModifyID);
  1008. ;    // Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1009. ;    // new script ID is created and returned.  If the current application has
  1010. ;    // a handler for the kOSARecordedText event, then kOSARecordedText events
  1011. ;    // are sent to the application containing the text of each AppleEvent 
  1012. ;    // recorded.
  1013. ;    //
  1014. ;    // Errors:
  1015. ;    //    badComponentInstance    invalid scripting component instance
  1016. ;    //     errOSASystemError
  1017. ;    //     errOSAInvalidID
  1018. ;    //    errOSARecordingIsAlreadyOn
  1019.  
  1020.         MACRO
  1021.         _OSAStartRecording
  1022.         MOVE.L    #((4<<16)|kOSASelectStartRecording),-(A7)
  1023.         MOVEQ    #$0,D0
  1024.         DC.W    $A82A    ; TB 002A
  1025.         ENDM
  1026.  
  1027. ;pascal OSAError
  1028. ;OSAStopRecording(ComponentInstance    scriptingComponent,
  1029. ;      OSAID        compiledScriptID);
  1030. ;    // If compiledScriptID is not being recorded into or recording is not
  1031. ;    // currently on, no error is returned.
  1032. ;    //
  1033. ;    // Errors:
  1034. ;    //    badComponentInstance    invalid scripting component instance
  1035. ;    //     errOSASystemError
  1036. ;    //     errOSAInvalidID
  1037.  
  1038.         MACRO
  1039.         _OSAStopRecording
  1040.         MOVE.L    #((4<<16)|kOSASelectStopRecording),-(A7)
  1041.         MOVEQ    #$0,D0
  1042.         DC.W    $A82A    ; TB 002A
  1043.         ENDM
  1044.  
  1045. ;////////////////////////////////////////////////////////////////////////////////
  1046. ;// OSA Optional Convenience Interface
  1047. ;////////////////////////////////////////////////////////////////////////////////
  1048. ;// Scripting components that support the Convenience interface have the 
  1049. ;// kOSASupportsConvenience bit set in it's ComponentDescription.
  1050. ;////////////////////////////////////////////////////////////////////////////////
  1051.  
  1052. ;pascal OSAError 
  1053. ;OSALoadExecute(ComponentInstance    scriptingComponent,
  1054. ;    const AEDesc*        scriptData,
  1055. ;    OSAID        contextID,
  1056. ;    long        modeFlags,
  1057. ;    OSAID*        resultingScriptValueID);
  1058. ;    // This routine is effectively equivalent to calling OSALoad followed by
  1059. ;    // OSAExecute.  After execution, the compiled source is disposed.  Only the
  1060. ;    // resulting value ID is retained.
  1061. ;    //
  1062. ;    // Errors:
  1063. ;    //    badComponentInstance    invalid scripting component instance
  1064. ;    //     errOSASystemError
  1065. ;    //     errOSABadStorageType:    scriptData not for this scripting component
  1066. ;    //     errOSACorruptData:        data seems to be corrupt
  1067. ;    //     errOSADataFormatObsolete    script data format is no longer supported
  1068. ;    //     errOSADataFormatTooNew        script data format is from a newer version
  1069. ;    //     errOSAInvalidID
  1070. ;    //     errOSAScriptError:        the executing script got an error
  1071. ;    //
  1072. ;    // ModeFlags:
  1073. ;    //    kOSAModeNeverInteract
  1074. ;    //    kOSAModeCanInteract
  1075. ;    //    kOSAModeAlwaysInteract
  1076. ;    //    kOSAModeCantSwitchLayer
  1077. ;    //    kOSAModeDontReconnect
  1078. ;    //    kOSAModeDoRecord
  1079.  
  1080.         MACRO
  1081.         _OSALoadExecute
  1082.         MOVE.L    #((16<<16)|kOSASelectStore),-(A7)
  1083.         MOVEQ    #$0,D0
  1084.         DC.W    $A82A    ; TB 002A
  1085.         ENDM
  1086.  
  1087. ;pascal OSAError 
  1088. ;OSACompileExecute(ComponentInstance    scriptingComponent,
  1089. ;       const AEDesc*    sourceData,
  1090. ;       OSAID        contextID,
  1091. ;       long        modeFlags,
  1092. ;       OSAID*        resultingScriptValueID);
  1093. ;    // This routine is effectively equivalent to calling OSACompile followed by
  1094. ;    // OSAExecute.  After execution, the compiled source is disposed.  Only the
  1095. ;    // resulting value ID is retained.
  1096. ;    //
  1097. ;    // Errors:
  1098. ;    //    badComponentInstance    invalid scripting component instance
  1099. ;    //     errOSASystemError
  1100. ;    //    errAECoercionFail:        sourceData is not compilable
  1101. ;    //     errOSAScriptError:        sourceData was a bad script (syntax error)
  1102. ;    //     errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1103. ;    //                            valid on input
  1104. ;    //     errOSAScriptError:        the executing script got an error
  1105. ;    //
  1106. ;    // ModeFlags:
  1107. ;    //    kOSAModeNeverInteract
  1108. ;    //    kOSAModeCanInteract
  1109. ;    //    kOSAModeAlwaysInteract
  1110. ;    //    kOSAModeCantSwitchLayer
  1111. ;    //    kOSAModeDontReconnect
  1112. ;    //    kOSAModeDoRecord
  1113.  
  1114.         MACRO
  1115.         _OSACompileExecute
  1116.         MOVE.L    #((16<<16)|kOSASelectCompileExecute),-(A7)
  1117.         MOVEQ    #$0,D0
  1118.         DC.W    $A82A    ; TB 002A
  1119.         ENDM
  1120.  
  1121. ;pascal OSAError 
  1122. ;OSADoScript(ComponentInstance    scriptingComponent,
  1123. ;            const AEDesc*    sourceData,
  1124. ;            OSAID    contextID,
  1125. ;            DescType    desiredType,
  1126. ;            long    modeFlags,
  1127. ;            AEDesc*    resultingText);
  1128. ;    // This routine is effectively equivalent to calling OSACompile followed by
  1129. ;    // OSAExecute and then OSADisplay.  After execution, the compiled source
  1130. ;    // and the resulting value are is disposed.  Only the resultingText
  1131. ;    // descriptor is retained.  If a script error occur during processing, the 
  1132. ;    // resultingText gets the error message of the error, and errOSAScriptError
  1133. ;    // is returned.  OSAScriptError may still be used to extract more 
  1134. ;    // information about the particular error.
  1135. ;    //
  1136. ;    // Errors:
  1137. ;    //    badComponentInstance    invalid scripting component instance
  1138. ;    //     errOSASystemError
  1139. ;    //    errAECoercionFail:    sourceData is not compilable or 
  1140. ;    //            desiredType not supported by scripting component
  1141. ;    //     errOSAScriptError:    sourceData was a bad script (syntax error)
  1142. ;    //     errOSAInvalidID:    previousAndResultingCompiledScriptID was not
  1143. ;    //            valid on input
  1144. ;    //     errOSAScriptError:    the executing script got an error
  1145. ;    //
  1146. ;    // ModeFlags:
  1147. ;    //    kOSAModeNeverInteract
  1148. ;    //    kOSAModeCanInteract
  1149. ;    //    kOSAModeAlwaysInteract
  1150. ;    //    kOSAModeCantSwitchLayer
  1151. ;    //    kOSAModeDontReconnect
  1152. ;    //    kOSAModeDoRecord
  1153. ;    //    kOSAModeDisplayForHumans
  1154.  
  1155.         MACRO
  1156.         _OSADoScript
  1157.         MOVE.L    #((20<<16)|kOSASelectDoScript),-(A7)
  1158.         MOVEQ    #$0,D0
  1159.         DC.W    $A82A    ; TB 002A
  1160.         ENDM
  1161.  
  1162. ;////////////////////////////////////////////////////////////////////////////////
  1163. ;// OSA Optional Dialects Interface
  1164. ;////////////////////////////////////////////////////////////////////////////////
  1165. ;// Scripting components that support the Dialects interface have the 
  1166. ;// kOSASupportsDialects bit set in it's ComponentDescription.
  1167. ;////////////////////////////////////////////////////////////////////////////////
  1168.  
  1169. ;// These calls allows an scripting component that supports different dialects
  1170. ;// to dynamically switch between those dialects.  Although this interface is
  1171. ;// specified, the particular dialect codes are scripting component dependent.
  1172.  
  1173. ;pascal OSAError 
  1174. ;OSASetCurrentDialect(ComponentInstance    scriptingComponent,
  1175. ;          short        dialectCode);
  1176. ;    //
  1177. ;    // Errors:
  1178. ;    //    badComponentInstance    invalid scripting component instance
  1179. ;    //     errOSASystemError
  1180. ;    //     errOSANoSuchDialect:    invalid dialectCode
  1181.  
  1182.         MACRO
  1183.         _OSASetCurrentDialect
  1184.         MOVE.L    #((2<<16)|kOSASelectSetCurrentDialect),-(A7)
  1185.         MOVEQ    #$0,D0
  1186.         DC.W    $A82A    ; TB 002A
  1187.         ENDM
  1188.  
  1189. ;pascal OSAError 
  1190. ;OSAGetCurrentDialect(ComponentInstance    scriptingComponent,
  1191. ;          short*        resultingDialectCode);
  1192. ;    //
  1193. ;    // Errors:
  1194. ;    //    badComponentInstance    invalid scripting component instance
  1195. ;    //     errOSASystemError
  1196.  
  1197.         MACRO
  1198.         _OSAGetCurrentDialect
  1199.         MOVE.L    #((4<<16)|kOSASelectGetCurrentDialect),-(A7)
  1200.         MOVEQ    #$0,D0
  1201.         DC.W    $A82A    ; TB 002A
  1202.         ENDM
  1203.  
  1204. ;pascal OSAError 
  1205. ;OSAAvailableDialects(ComponentInstance    scriptingComponent,
  1206. ;          AEDesc*        resultingDialectInfoList);
  1207. ;    // This call return an AEList containing information about each of the
  1208. ;    // currently available dialects of a scripting component.  Each item
  1209. ;    // is an AERecord of typeOSADialectInfo that contains at least the fields
  1210. ;    // keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1211. ;    // keyOSADialectScriptCode.
  1212. ;    //
  1213. ;    // Errors:
  1214. ;    //    badComponentInstance    invalid scripting component instance
  1215. ;    //     errOSASystemError
  1216.  
  1217.         MACRO
  1218.         _OSAAvailableDialects
  1219.         MOVE.L    #((4<<16)|kOSASelectAvailableDialects),-(A7)
  1220.         MOVEQ    #$0,D0
  1221.         DC.W    $A82A    ; TB 002A
  1222.         ENDM
  1223.  
  1224. ;pascal OSAError
  1225. ;OSAGetDialectInfo(ComponentInstance    scriptingComponent,
  1226. ;       short        dialectCode,
  1227. ;       OSType        selector,
  1228. ;       AEDesc*        resultingDialectInfo);
  1229. ;    // This call gives information about the specified dialect of a scripting
  1230. ;    // component. It returns an AEDesc whose type depends on the selector 
  1231. ;    // specified. Available selectors are the same as the field keys for a
  1232. ;    // dialect info record. The type of AEDesc returned is the same as the 
  1233. ;    // type of the field that has same key as the selector.
  1234. ;    //
  1235. ;    // Errors:
  1236. ;    //    badComponentInstance    invalid scripting component instance
  1237. ;    //     errOSASystemError
  1238. ;    //  errOSABadSelector
  1239. ;    //     errOSANoSuchDialect:    invalid dialectCode
  1240.  
  1241.         MACRO
  1242.         _OSAGetDialectInfo
  1243.         MOVE.L    #((10<<16)|kOSASelectGetDialectInfo),-(A7)
  1244.         MOVEQ    #$0,D0
  1245.         DC.W    $A82A    ; TB 002A
  1246.         ENDM
  1247.  
  1248. ;pascal OSAError 
  1249. ;OSAAvailableDialectCodeList(ComponentInstance    scriptingComponent,
  1250. ;        AEDesc*        resultingDialectCodeList);
  1251. ;    // This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1252. ;    // and  OSAGetDialectInfo to get information on dialects.
  1253. ;    // This call return an AEList containing dialect code for each of the
  1254. ;    // currently available dialects of a scripting component. Each dialect
  1255. ;    // code is a short integer of type typeShortInteger.
  1256. ;    //
  1257. ;    // Errors:
  1258. ;    //    badComponentInstance    invalid scripting component instance
  1259. ;    //     errOSASystemError
  1260.  
  1261.         MACRO
  1262.         _OSAAvailableDialectCodeList
  1263.         MOVE.L    #((4<<16)|kOSASelectAvailableDialectCodeList),-(A7)
  1264.         MOVEQ    #$0,D0
  1265.         DC.W    $A82A    ; TB 002A
  1266.         ENDM
  1267.  
  1268. typeOSADialectInfo    EQU    'difo'
  1269. ;    // Type of a dialect info record containing at least keyOSADialectName
  1270. ;    // and keyOSADialectCode fields.
  1271.  
  1272. ;// keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1273.  
  1274. keyOSADialectName    EQU    'dnam'
  1275. ;    // Field of a typeOSADialectInfo record of typeChar.
  1276. keyOSADialectCode    EQU    'dcod'
  1277. ;    // Field of a typeOSADialectInfo record of typeShortInteger.
  1278. keyOSADialectLangCode    EQU    'dlcd'
  1279. ;    // Field of a typeOSADialectInfo record of typeShortInteger.
  1280. keyOSADialectScriptCode    EQU    'dscd'
  1281. ;    // Field of a typeOSADialectInfo record of typeShortInteger.
  1282.  
  1283. ;////////////////////////////////////////////////////////////////////////////////
  1284. ;// OSA Optional Event Handling Interface
  1285. ;////////////////////////////////////////////////////////////////////////////////
  1286. ;// Scripting components that support the Event Handling interface have the 
  1287. ;// kOSASupportsEventHandling bit set in it's ComponentDescription.
  1288. ;////////////////////////////////////////////////////////////////////////////////
  1289.  
  1290. ;pascal OSAError
  1291. ;OSASetResumeDispatchProc(ComponentInstance    scriptingComponent,
  1292. ;              AEHandlerProcPtr    resumeDispatchProc,
  1293. ;              long        refCon);
  1294. ;    // This function is used to set the ResumeDispatchProc that will be used
  1295. ;    // by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1296. ;    // found in the context, or the context event hander "continues" control
  1297. ;    // onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1298. ;    // may also be passed to this routine indicating that the handler registered
  1299. ;    // in the application with AEInstallEventHandler should be used, or no
  1300. ;    // dispatch should occur, respectively.
  1301. ;    //
  1302. ;    // Errors:
  1303. ;    //    badComponentInstance    invalid scripting component instance
  1304. ;    //     errOSASystemError
  1305.  
  1306.         MACRO
  1307.         _OSASetResumeDispatchProc
  1308.         MOVE.L    #((8<<16)|kOSASelectSetResumeDispatchProc),-(A7)
  1309.         MOVEQ    #$0,D0
  1310.         DC.W    $A82A    ; TB 002A
  1311.         ENDM
  1312.  
  1313. kOSAUseStandardDispatch    EQU    kAEUseStandardDispatch
  1314. ;    // Special ResumeDispatchProc constant which may be passed to 
  1315. ;    // OSASetResumeDispatchProc indicating that the handler registered
  1316. ;    // in the application with AEInstallEventHandler should be used.
  1317.  
  1318. kOSANoDispatch        EQU    kAENoDispatch
  1319. ;    // Special ResumeDispatchProc constant which may be passed to 
  1320. ;    // OSASetResumeDispatchProc indicating that no dispatch should occur.
  1321.  
  1322. kOSADontUsePhac        EQU    $0001
  1323. ;    // Special refCon constant that may be given to OSASetResumeDispatchProc
  1324. ;    // only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1325. ;    // This causes the standard dispatch to be performed, except the phac
  1326. ;    // handler is not called.  This is useful during tinkerability, when
  1327. ;    // the phac handler is used to lookup a context associated with an event's 
  1328. ;    // direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1329. ;    // bypass the phac handler would result in an infinite loop.
  1330.  
  1331. ;pascal OSAError
  1332. ;OSAGetResumeDispatchProc(ComponentInstance    scriptingComponent,
  1333. ;              AEHandlerProcPtr*    resumeDispatchProc,
  1334. ;              long*        refCon);
  1335. ;    // Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1336. ;    // been registered, then kOSAUseStandardDispatch (the default) is returned.
  1337. ;    //
  1338. ;    // Errors:
  1339. ;    //    badComponentInstance    invalid scripting component instance
  1340. ;    //     errOSASystemError
  1341.  
  1342.         MACRO
  1343.         _OSAGetResumeDispatchProc
  1344.         MOVE.L    #((8<<16)|kOSASelectGetResumeDispatchProc),-(A7)
  1345.         MOVEQ    #$0,D0
  1346.         DC.W    $A82A    ; TB 002A
  1347.         ENDM
  1348.  
  1349. ;pascal OSAError
  1350. ;OSAExecuteEvent(ComponentInstance    scriptingComponent,
  1351. ;     const AppleEvent*    theAppleEvent,
  1352. ;     OSAID        contextID,
  1353. ;     long        modeFlags,
  1354. ;     OSAID*        resultingScriptValueID);
  1355. ;    // This call is similar to OSAExecute except the initial command to
  1356. ;    // execute comes in the form of an AppleEvent.  If the contextID
  1357. ;    // defines any event handlers for that event, they are used to process
  1358. ;    // the event.  If no event handler can be found in the context
  1359. ;    // errAEEventNotHandled is returned.  If an event handler is found and
  1360. ;    // the hander "continues" control onward, the ResumeDispatchProc
  1361. ;    // (registered with OSASetResumeDispatchProc, above) is called given the
  1362. ;    // AppleEvent.  The result is returned as a scriptValueID.
  1363. ;    //
  1364. ;    // Errors:
  1365. ;    //    badComponentInstance    invalid scripting component instance
  1366. ;    //     errOSASystemError
  1367. ;    //     errOSAInvalidID
  1368. ;    //     errOSAScriptError:        the executing script got an error
  1369. ;    //     errAEEventNotHandled:    no handler for event in contextID
  1370. ;    //
  1371. ;    // ModeFlags:
  1372. ;    //    kOSAModeNeverInteract
  1373. ;    //    kOSAModeCanInteract
  1374. ;    //    kOSAModeAlwaysInteract
  1375. ;    //    kOSAModeCantSwitchLayer
  1376. ;    //    kOSAModeDontReconnect
  1377. ;    //    kOSAModeDoRecord
  1378.  
  1379.         MACRO
  1380.         _OSAExecuteEvent
  1381.         MOVE.L    #((16<<16)|kOSASelectExecuteEvent),-(A7)
  1382.         MOVEQ    #$0,D0
  1383.         DC.W    $A82A    ; TB 002A
  1384.         ENDM
  1385.  
  1386. ;pascal OSAError
  1387. ;OSADoEvent(ComponentInstance    scriptingComponent,
  1388. ;           const AppleEvent*    theAppleEvent,
  1389. ;           OSAID    contextID,
  1390. ;           long    modeFlags,
  1391. ;           AppleEvent*    reply);
  1392. ;    // This call is similar to OSADoScript except the initial command to
  1393. ;    // execute comes in the form of an AppleEvent, and the result is an 
  1394. ;    // AppleEvent reply record.  If the contextID defines any event handlers
  1395. ;    // for that event, they are used to process the event.  If no event handler
  1396. ;    // can be found in the context errAEEventNotHandled is returned.  If an
  1397. ;    // event handler is found and the hander "continues" control onward, the
  1398. ;    // ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1399. ;    // called given the AppleEvent.  The result is returned in the form of an
  1400. ;    // AppleEvent reply descriptor. If at any time the script gets an error, or
  1401. ;    // if the ResumeDispatchProc returns a reply event indicating an error,
  1402. ;    // then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1403. ;    // should never return errOSAScriptError).  Any error result returned by
  1404. ;    // the ResumeDispatchProc will be returned by OSADoEvent.
  1405. ;    //
  1406. ;    // Errors:
  1407. ;    //    badComponentInstance    invalid scripting component instance
  1408. ;    //     errOSASystemError
  1409. ;    //     errOSAInvalidID
  1410. ;    //     errAEEventNotHandled:    no handler for event in contextID
  1411. ;    //
  1412. ;    // ModeFlags:
  1413. ;    //    kOSAModeNeverInteract
  1414. ;    //    kOSAModeCanInteract
  1415. ;    //    kOSAModeAlwaysInteract
  1416. ;    //    kOSAModeCantSwitchLayer
  1417. ;    //    kOSAModeDontReconnect
  1418. ;    //    kOSAModeDoRecord
  1419.  
  1420.         MACRO
  1421.         _OSADoEvent
  1422.         MOVE.L    #((16<<16)|kOSASelectStore),-(A7)
  1423.         MOVEQ    #$0,D0
  1424.         DC.W    $A82A    ; TB 002A
  1425.         ENDM
  1426.  
  1427. ;pascal OSAError
  1428. ;OSAMakeContext(ComponentInstance    scriptingComponent,
  1429. ;    const AEDesc*        contextName,
  1430. ;    OSAID        parentContext,
  1431. ;    OSAID*        resultingContextID);
  1432. ;    // Makes a new empty context which may be passed to OSAExecute or 
  1433. ;    // OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1434. ;    // created. If parentContext is kOSANullScript then the resulting context
  1435. ;    // does not inherit bindings from any other context.
  1436. ;    //
  1437. ;    // Errors:
  1438. ;    //    badComponentInstance    invalid scripting component instance
  1439. ;    //     errOSASystemError
  1440. ;    //     errOSAInvalidID
  1441. ;    //     errAECoercionFail:        contextName is invalid
  1442.  
  1443.         MACRO
  1444.         _OSAMakeContext
  1445.         MOVE.L    #((12<<16)|kOSASelectMakeContext),-(A7)
  1446.         MOVEQ    #$0,D0
  1447.         DC.W    $A82A    ; TB 002A
  1448.         ENDM
  1449.  
  1450. ;////////////////////////////////////////////////////////////////////////////////
  1451. ;// You're still here?  Go home.
  1452.  ENDIF
  1453. ;////////////////////////////////////////////////////////////////////////////////
  1454.